<!--
 * @Description: 
 * @Version: 1.0
 * @Autor: younghxp
 * @Date: 2021-11-08 16:11:40
 * @LastEditors: younghxp
 * @LastEditTime: 2021-11-22 14:14:58
-->
<template>
  <div class="wrapBox">
    <topTitle
      :titleText="titleText"
      :back="back"
      @gobackTriser="goback"
    ></topTitle>
    <div class="detailBox">
      <!-- 进度条 -->
      <new-progress :step="step"></new-progress>
      <!-- 投保登记 -->
      <insurance-reg
        @changeStep="changeStep"
        @changeStatus="changeStatus"
        @changeId="changeId"
        @changeIsDetail="changeIsDetail"
        v-if="!status"
        :id="id"
        :type="type"
      ></insurance-reg>
      <!-- 投保成功待审核 -->
      <insurance-examine
        @changeIsDetail="changeIsDetail"
        v-if="status && !isDetail"
      ></insurance-examine>
      <!-- 订单详情 -->
      <insurance-detail
        @changeStep="changeStep"
        @changeStatus="changeStatus"
        @changeType="changeType"
        v-if="status && isDetail"
        :status="status"
        :id="id"
      ></insurance-detail>
    </div>
  </div>
</template>

<script>
import newProgress from './newProgress.vue'
import insuranceReg from './insuranceReg.vue'
import insuranceExamine from './insuranceExamine.vue'
import insuranceDetail from './insuranceDetail.vue'
export default {
  name: 'insuranceOrderProgress',
  components: {
    newProgress,
    insuranceReg,
    insuranceExamine,
    insuranceDetail,
  },
  data() {
    return {
      titleText: '返回',
      back: 'true',
      step: '1',
      status: '', //列表=>有状态,新增=>无状态status=''
      isDetail: true, //true详情/false投保成功
      id: '',
      type: '', //update修改资料/add投保登记/renew续保
    }
  },
  created() {
    const { step, status, id, type, rejectUserType } = this.$route.query
    this.step = step || '1'
    this.id = id || ''
    this.type = type || ''
    this.status = status || ''
    if (status === 'CANCEL') {
      this.step = '1'
    }
    // 待监管部门审核/审核不通过(承保机构审核”；当是某级监管部门驳回,待出函),
    if (
      status === 'SENDING' ||
      (status === 'AUDITFAILED' && rejectUserType === 'MONITOR') ||
      status === 'JCAUDITING'
    ) {
      this.step = '3'
    }
    if (status === 'SENT' || status === 'OVERDUE') {
      this.step = '4'
    }
  },
  methods: {
    goback() {
      this.$router.push({
        path: '/home/newInsurance/insuranceOrder',
        name: 'insuranceOrder',
      })
      this.$store.commit('GOBACK_NAME', {
        oldUrl: '/home/newInsurance/insuranceOrder',
        newUrl: this.$router.currentRoute.fullPath,
      })
    },
    changeStep(val) {
      this.step = val
    },
    changeStatus(val) {
      this.status = val
      if (this.status === 'CANCEL') {
        this.step = '1'
      }
      if (this.status === 'JCAUDITING') {
        this.step = '3'
      }
      if (this.status === 'SENT' || this.status === 'OVERDUE') {
        this.step = '4'
      }
    },
    changeIsDetail(val) {
      this.isDetail = val
    },
    changeId(val) {
      this.id = val
    },
    changeType(val) {
      this.type = val
    },
  },
}
</script>

<style lang="less" scoped>
.detailBox {
  width: 940px;
  margin: 0 auto;
  padding: 24px 0 40px 0;
}
@import '../../../static/css/filterArea.less';
</style>
